package com.example.flo;

import ag.AGContext;
import ag.AGModel;
import ag.AGModelManager;
import ag.AGObject;
import ag.AGView;
import ag.ui.AGButton;
import ag.ui.AGControl;
import ag.ui.IAGEventHandler;
import android.graphics.PointF;
import android.graphics.RectF;

public class TestView2 extends AGView {

	private AGModel _model2;
	private AGObject _objBackground1;
	
	private AGModel _model;
	private AGButton _btnOK;
	
	public TestView2() {
		super();
		// TODO Auto-generated constructor stub
		
		this._model2 = AGModelManager.getInstance().getModel(2);
		this._objBackground1 = AGObject.createObject(this._model2);
		this.addObject(this._objBackground1);
		this._objBackground1.setAction(1);
		this._objBackground1.setPosition(new PointF(0,0));
		this._objBackground1.setZIndex(0);
		
		this._model = AGModelManager.getInstance().getModel(1);
		this._btnOK = new AGButton(new RectF(400,300, 600, 350), this._model);
		this.addControl(this._btnOK);
		this._btnOK.addClickEvent(new ButtonOKClick(this));
	}

	@Override
	public void onRender(AGContext context) {
		// TODO Auto-generated method stub
	}

	@Override
	public void onUpdate(AGContext context) {
		// TODO Auto-generated method stub
		
	}

	class ButtonOKClick implements IAGEventHandler{
		private TestView2 _view;
		public ButtonOKClick(TestView2 view){
			this._view = view;
		}
		
		@Override
		public void onHandle(AGControl control) {
			// TODO Auto-generated method stub
			//_view.addAnimation(new AGPositionAnimation(_view._object2, new PointF(500,500), 5000))
			//	.addComplatedHanlder(new AnimationCompleted(_view));
			//control.setVisible(false);
			this._view.switchView(new TestView1());
		}
	}
}